package com.zktr.servlet;

import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
/**

 * 监听器：
 */
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.zktr.pojo.Category;
import com.zktr.pojo.Goods;
import com.zktr.pojo.GoodsGallery;
import com.zktr.service.CategoryService;
import com.zktr.service.GoodsGalleryService;
import com.zktr.service.GoodsService;

public class WebContextListener implements ServletContextListener {
	

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		CategoryService categoryService=new CategoryService();
		GoodsGalleryService goodsGalleryService=new GoodsGalleryService();
		GoodsService goodsService=new GoodsService();
		System.out.println("初始化");
		Map<Category, Map<Category, List<Category>>> categorymap = categoryService.queryAll();
		List<GoodsGallery> queryIndexSlideshow = goodsGalleryService.queryIndexSlideshow();
		List<GoodsGallery> queryAdimg = goodsGalleryService.queryAdimg();
		List<GoodsGallery> queryAdingRight = goodsGalleryService.queryAdingRight();
		List<Goods> queryIndex = goodsService.queryIndex();
		ServletContext servletContext = sce.getServletContext();
		servletContext.setAttribute("categorymap", categorymap);
		servletContext.setAttribute("slideshowlist",queryIndexSlideshow);
		servletContext.setAttribute("adimg", queryAdimg);
		servletContext.setAttribute("adimgright", queryAdingRight);
		servletContext.setAttribute("miaosha", queryIndex);
		
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		System.out.println("销毁");

	}

}
